package com.woniu.sharepark.leasesystem.common.controller;

import com.woniu.sharepark.common.JsonResult;
import com.woniu.sharepark.leasesystem.common.pojo.CarParkCommentReply;
import com.woniu.sharepark.leasesystem.common.service.CarParkCommentReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 *@ClassName CarParkCommentReplyController
 *@Description 对前端评论的回复请求处理的controller
 *@Author litong
 *@Date 2019/6/4 10:10
 *@Version 1.0
 **/
@Controller
@RequestMapping("/CommentReply")
public class CarParkCommentReplyController {
    @Autowired
   private CarParkCommentReplyService carParkCommentReplyService;

    /**
    * 根据评论id查找对应的所有回复
    * @title findAllRepliesByCpcId
    * @param cpcId 评论id
    * @return java.util.List
    * @author litong
    * @date 2019/6/4 11:53
    **/
    @RequestMapping("/allReplies")
    @ResponseBody
    public List findAllRepliesByCpcId(Integer cpcId){
        List<CarParkCommentReply>replies=new ArrayList<>();
        replies=carParkCommentReplyService.findAllReplysByCpcId(cpcId);
        return  replies;
    }
    /**
    * 回复评论
    * @title  addReply
    * @param carParkCommentReply
    * @return com.woniu.sharepark.common.JsonResult
    * @author litong
    * @date 2019/6/4 19:03
    **/
    @RequestMapping("/addReply")
    @ResponseBody
    public JsonResult addReply(CarParkCommentReply carParkCommentReply){
        return carParkCommentReplyService.addReply(carParkCommentReply);
    }
    /**
    * 通过主键删除对应回复（软删除）
    * @title deleteReply
    * @param cpcrId
    * @return com.woniu.sharepark.common.JsonResult
    * @author litong
    * @date 2019/6/4 19:04
    **/
    @RequestMapping("/deleteReply")
    @ResponseBody
    public JsonResult deleteReply(Integer cpcrId){
       return carParkCommentReplyService.deleteReply(cpcrId);
    }
}
